package date;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

class text {
    public static void main(String[] args) {
       /* Calendar c= Calendar.getInstance();
        Calendar c1= new GregorianCalendar();//子类
        //只能通过静态方法生成一个实例，不能new
        Date date = c.getTime();
        //设置
        System.out.println(date);
        c.setTime(new Date(0l));
        //毫秒值 获取
        System.out.println(c.getTime());
        //设置毫秒值
        c.setTimeInMillis(24*60*60*1000*2l);
        System.out.println(c.getTime());*/
        Calendar c = Calendar.getInstance();
        int year = c.get(1);//对应的域的含义：查看源码
        System.out.println(year);
        int month = c.get(2);
        System.out.println(month);//1-12 系统0-11
        int day = c.get(5);
        System.out.println(day);//1-12
        int week=c.get(7);
        System.out.println(week);
        //设置年
        c.set(1,2025);
        System.out.println(c.getTime());
        c.set(2011,10,1);
        System.out.println(c.getTime());
        c.add(2,5);
        System.out.println(c.getTime());
        c.add(5,-60);//2012-4-1>>>-60
        System.out.println(c.getTime());
    }
}